import TableData from "@/components/waterManage/public/el-tables"; //主页面列表
import formJs from "./regexDetail.js"; //新增弹框配置项
import entryledgerDialog from "@/components/rawMaterialManage/entryLedgerText/index.vue";
import checkSampleDialog from "@/components/sampleManage/fieldSampling/index.vue";
// 外委不合格报告
import outDialog from "@/components/outsourcedManage/outUnQualifiedReports/index.vue";
// 混凝土
import hunnintuDialog from "@/components/machineNetworkManage/pressDataMonitor/index.vue";
// 钢筋
import gangjinDialog from "@/components/machineNetworkManage/zigzagDataMonitor/index.vue";
// 水泥不合格
import shuiniDialog from "@/components/machineNetworkManage/compressivePressDataMonitor/index.vue";
// 外委合格
import outhegeDialog from "@/components/outsourcedManage/qualificationReport/index.vue";
// 试验检测管理不合格
import testDialog from "@/components/testDetectionManage/unqualifiedReport/index.vue";
// 试验机联网闭合
import biheDialog from "@/components/machineNetworkManage/pressDataProcess/index.vue";

import {
    getledgerByFid, //详情
} from "@/api/request.js";
export default {
    props: [
        "dialogVisible",
        "statusNum",
        "currentRow",
    ],
    data() {
        return {
            visible: "",
            loading: false,
            entryledger_config: formJs.entryledger_config, //进场批次
            checkSample_config: formJs.checkSample_config, // 样品取样
            checkSamples_config: formJs.checkSamples_config, // 样品收样
            testMortarFlexural_config: formJs.testMortarFlexural_config, // 试验机监控
            report_config: formJs.report_config, //检测报告
            Nonreport_config: formJs.Nonreport_config, //不i合格报告
            displaySwitching: null,
            isLock: false,
            dialogHeight: null,
            tableData: [],
            currentDetail: null,
            listLoading: true,
            rowDetail: null,
            entryledgerShow: false, //进场
            checkSampleShow: false, //取样
            outShow: false, //外委不合格报告
            hunnintuShow: false, //混凝土不合格
            gangjinShow: false, //钢筋
            shuiniShow: false, //水泥
            outhegeShow: false, //外委合格
            testShow: false, // 试验检测管理不合格
            biheShow: false, //试验机联网闭合
            tableTitle: null,
            flagNum: null,
            keyType: null,
            closeType: null
        };
    },
    components: {
        TableData,
        entryledgerDialog, //进场
        checkSampleDialog, //样品取样
        outDialog, //外委不合格报告
        hunnintuDialog, //混凝土不合格
        gangjinDialog, //钢筋不合格
        shuiniDialog, // 水泥不合格
        outhegeDialog, //外委合格
        testDialog, // 试验检测管理不合格
        biheDialog // 试验机联网闭合

    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
        currentRow: {
            handler(newVal) {
                if (newVal) {
                    this.currentDetail = newVal;
                    // if (this.statusNum != 1) {

                    // }
                }
            },
            immediate: true,
        },

    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.getHeight();
    }, //获取页面高度自适应：

    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },
    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("yjSmart-userInfo"));
        this.btnShow = true

        if (this.statusNum == 7) { //查看
            this.getDetail({
                fId: this.currentDetail.fId
            })

        }
        this.getHeight();
    },
    methods: {
        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 0.76 + "px";
        },
        handleSelect(key) {
            this.activeIndex = key;
        },
        closeDialog() {
            this.$emit("close");
        },
        ClickOnLine(row, status) {
            this.rowDetail = row
            if (status == 0) { //进场批次
                this.entryledgerShow = true;
            } else if (status == 1) { //取样
                this.displaySwitching = 0;
                this.checkSampleShow = true;
            } else if (status == 2) { //收样
                this.displaySwitching = 2;
                this.checkSampleShow = true;
            } else if (status == 3) { //试验机联网
                if (row.SYLX == '芯样强度') {
                    this.hunnintuShow = true;
                    this.tableTitle = "水泥混凝土芯样强度原始采集数据记录";
                } else if (row.SYLX == '抗折强度') {
                    this.hunnintuShow = true;
                    this.tableTitle = "水泥混凝土抗折强度原始采集数据记录";
                } else if (row.SYLX == '抗压强度') {
                    this.hunnintuShow = true;
                    this.tableTitle = "水泥混凝土抗压强度原始采集数据记录";
                } else if (row.SYLX == '钢筋试验') {
                    this.flagNum = 1
                    this.gangjinShow = true;
                    this.tableTitle = "金属拉伸试验原始采集数据记录";
                } else if (row.SYLX == '钢筋焊接') {
                    this.flagNum = 2
                    this.gangjinShow = true;
                    this.tableTitle = "钢筋焊接接头试验原始采集数据记录";
                } else if (row.SYLX == '机械连接') {
                    this.tableTitle = "钢筋机械连接接头试验原始采集数据记录";
                    this.flagNum = 3
                    this.gangjinShow = true;
                } else if (row.SYLX == '水泥胶砂抗压') {
                    this.shuiniShow = true;
                    this.flagNum = 1
                    this.keyType = row.SYLX

                    this.tableTitle = "水泥抗压强度原始采集数据记录";
                } else if (row.SYLX == '水泥胶砂抗折') {
                    this.shuiniShow = true;
                    this.flagNum = 2
                    this.keyType = row.SYLX

                    this.tableTitle = "水泥胶砂抗折强度试验原始采集数据记录";
                } else if (row.SYLX == '水泥净浆抗压') {
                    this.shuiniShow = true;
                    this.tableTitle = "水泥净浆抗压强度试验原始采集数据记录";
                    this.flagNum = 3
                    this.keyType = row.SYLX

                } else if (row.SYLX == '水泥净浆抗折') {
                    this.shuiniShow = true;
                    this.tableTitle = "水泥净浆抗折强度试验原始采集数据记录";
                    this.flagNum = 4
                    this.keyType = row.SYLX

                } else if (row.SYLX == '水泥砂浆抗压') {
                    this.shuiniShow = true;
                    this.tableTitle = "水泥砂浆抗压强度试验原始采集数据记录";
                    this.flagNum = 5
                    this.keyType = row.SYLX
                }
            } else if (status == 4) { //检测报告
                // 外委
                if (row.fChecktype == '监理外委' || row.fChecktype == '施工外委') { //检测类型
                    this.outhegeShow = true;
                } else { //自检
                    // 链接
                    if (row.fReporturl != "/" && row.fReporturl != "" && row.fReporturl != null) {
                        window.open(row.fReporturl, '_blank');
                    } else {
                        this.$message.warning("试验报告暂未出具");
                    }
                }
            } else if (status == 5) { //不合格报告
                // 外委
                if (row.type == '试验机监控') { //检测类型
                    this.biheShow = true;
                    if (row.SYLX == '芯样强度') {
                        this.closeType = "1"
                        this.tableTitle = "水泥混凝土芯样强度原始采集数据记录";
                    } else if (row.SYLX == '抗折强度') {
                        this.closeType = "1"

                        this.tableTitle = "水泥混凝土抗折强度原始采集数据记录";
                    } else if (row.SYLX == '抗压强度') {
                        this.closeType = "1"

                        this.tableTitle = "水泥混凝土抗压强度原始采集数据记录";
                    } else if (row.SYLX == '钢筋试验') {
                        this.flagNum = 1
                        this.closeType = "2"
                        this.tableTitle = "金属拉伸试验原始采集数据记录";
                    } else if (row.SYLX == '钢筋焊接') {
                        this.flagNum = 2
                        this.closeType = "2"
                        this.tableTitle = "钢筋焊接接头试验原始采集数据记录";
                    } else if (row.SYLX == '机械连接') {
                        this.tableTitle = "钢筋机械连接接头试验原始采集数据记录";
                        this.flagNum = 3
                        this.closeType = "2"
                    } else if (row.SYLX == '水泥胶砂抗压') {
                        this.closeType = 3;
                        this.flagNum = 1
                        this.keyType = row.SYLX
                        this.tableTitle = "水泥抗压强度原始采集数据记录";
                    } else if (row.SYLX == '水泥胶砂抗折') {
                        this.flagNum = 2
                        this.keyType = row.SYLX
                        this.closeType = 3;
                        this.tableTitle = "水泥胶砂抗折强度试验原始采集数据记录";
                    } else if (row.SYLX == '水泥净浆抗压') {
                        this.closeType = 4;
                        this.tableTitle = "水泥净浆抗压强度试验原始采集数据记录";
                        this.flagNum = 3
                        this.keyType = row.SYLX
                    } else if (row.SYLX == '水泥净浆抗折') {
                        this.closeType = 4;
                        this.tableTitle = "水泥净浆抗折强度试验原始采集数据记录";
                        this.flagNum = 4
                        this.keyType = row.SYLX
                    } else if (row.SYLX == '水泥砂浆抗压') {
                        this.closeType = 5;
                        this.tableTitle = "水泥砂浆抗压强度试验原始采集数据记录";
                        this.flagNum = 5
                        this.keyType = row.SYLX
                    }
                } else if (row.type == '检测报告') { //自检
                    // 外委
                    if (row.fChecktype == '监理外委' || row.fChecktype == '施工外委') { //检测类型
                        this.outShow = true;
                    } else { //自检 // 试验检测管理不合格
                        this.testShow = true
                    }
                }
            }

        },
        biheCloseDialog() { //试验及联网闭合
            this.biheShow = false
        },
        entryledgerCloseDialog() { //进场批次
            this.entryledgerShow = false
        },
        checkSampleCloseDialog() { //取样
            this.checkSampleShow = false
        },
        outhegeCloseDialog() { //外委合格报告
            this.outhegeShow = false
        },
        outCloseDialog() { //外委不合格报告
            this.outShow = false
        },
        hunnintuCloseDialog() { //混凝土不合格报告
            this.hunnintuShow = false
        },
        gangjinCloseDialog() { //钢筋不合格报告
            this.gangjinShow = false
        },
        testCloseDialog() { // 试验检测管理不合格
            this.testShow = false
        },
        // 详情
        getDetail(obj) {
            this.loading = true;
            getledgerByFid(obj).then((res) => {
                if (res.errcode == 0) {
                    var data = res.data
                    this.loading = false;
                    this.listLoading = false
                    this.tableData = data
                } else {
                    this.loading = false;
                    this.$message.error(res.msg);
                }
            });
        },
    },
};